package com.example.jiancaiwang.utils;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.example.jiancaiwang.R;

public class GlideUtils {
    /**
     * 普通图片
     * @param context
     * @param path
     * @param imageView
     */
    public static void displayImage(Context context, Object path, ImageView imageView){
        Glide.with(context)
                .load(path)
                .placeholder(R.drawable.black_background)//占位符
                .error(R.drawable.black_background)//加载失败
                .transform(new CenterCrop())//居中裁剪 填充
                .into(imageView);
    }

    /**
     * 圆形头像
     * @param context
     * @param path
     * @param imageView
     */
    public static void displayCircleImage(Context context, Object path, ImageView imageView){
        Glide.with(context)
                .load(path)
                .placeholder(R.drawable.black_background)//占位符
                .error(R.drawable.black_background)//加载失败
                .transform(new CircleCrop())//圆形裁剪 填充
                .into(imageView);
    }

    /**
     * 圆角头像
     * @param context
     * @param path
     * @param imageView
     */
    public static void displayRoundedImage(Context context, Object path, ImageView imageView,int radius){
        Glide.with(context)
                .load(path)
                .placeholder(R.drawable.black_background)//占位符
                .error(R.drawable.black_background)//加载失败
                .transform(new CenterCrop(),new RoundedCorners(radius))//圆角裁剪 填充
                .into(imageView);
    }

}
